<template>
  <div class="box">
    <RenderTable 
      :superQueryFieldList="superQueryFieldList" 
      :queryParamArr = "queryParamArr"
      :defColumns="defColumns"
      :isShowRowSelection = "true"
      :isShowDeleteBatch = "true"
      :url = "url"
      @handleEdit = "handleEdit"
      ref='renderTable'
    >
    
      <template slot="btn">
        <p-button type="primary" @click="showAddModal" style="margin-right: 10px">新增</p-button>
      </template>

    </RenderTable>

    <SkillBankListModal ref='skillBankListModal' @handleSuccess = 'handleSuccess'></SkillBankListModal>

  </div>
</template>

<script type="text/javascript">
import { getDictItemsArr } from "@/utils/util";
import RenderTable from '@/components/renderTable'
import SkillBankListModal from './modules/skillBankListModal.vue'
import { timestampToDatetime } from "@/utils/util";

const superQueryFieldList =
[
  {
    value: "organization",
    text: "组织",
    type: "String",
  },  
  {
    value: "empname",
    text: "员工姓名",
    type: "String",
  },
]
export default {
  data() {
    return {
      superQueryFieldList,
      queryParamArr: [
        {
          label: "技能名称",
          placeholder: "请输入技能名称",
          type: 'input',
          key: 'skillName',
          value: ''
        }
      ],
      defColumns: [
        {
          title: "序号",
          dataIndex: "",
          key: "rowIndex",
          width: 60,
          align: "center",
          customRender: (t, r, index) => {
            return parseInt(index) + 1;
          },
        },
        {
          title: "技能代码",
          align: "center",
          dataIndex: "skillCode",
          fixed: 'left'
        },
        {
          title: "技能分类",
          align: "center",
          dataIndex: "skillType",
          customRender: (t, r, index) => {
            return this.skillTypeKeys[t];
          },
          fixed: 'left'
        },
        {
          title: "技能名称",
          align: "center",
          dataIndex: "skillName",
          fixed: 'left'
        },
        {
          title: "技能属性",
          align: "center",
          dataIndex: "skillProperty",
          customRender: (t, r, index) => {
            return this.skillPropertyKeys[t]
          },           
        },
        {
          title: "是否线长确认",
          align: "center",
          dataIndex: "lineleaderConfirm",
          customRender: (t, r, index) => {
            return {0: '否', 1: '是'}[t]
          },          
        },
        {
          title: "复核到期提前时间",
          align: "center",
          dataIndex: "beforeReviewTimes",
        },
        {
          title: "创建日期",
          align: "center",
          dataIndex: "createTime",
          customRender: (t, r, index) => {
            return timestampToDatetime(t)
          },          
        },
        {
          title: "创建人",
          align: "center",
          dataIndex: "createBy",
        },
        {
          title: "见习时长",
          align: "center",
          dataIndex: "traineeTime",
        },
        {
          title: "通识合格分",
          align: "center",
          dataIndex: "generalPassingScore",
        },
        {
          title: "技能合格分",
          align: "center",
          dataIndex: "skillPassingScore",
        },
        {
          title: "线长确认合格分",
          align: "center",
          dataIndex: "lineleaderPassingScore",
        },
        {
          title: "见习合格分",
          align: "center",
          dataIndex: "traineePassingScore",
        },
        {
          title: "复核合格分",
          align: "center",
          dataIndex: "reviewPassingScore",
        },
        {
          title: "状态",
          align: "center",
          dataIndex: "status",
          scopedSlots: { customRender: "status" },
        },
        {
          title: "操作",
          dataIndex: "action",
          align: "center",
          scopedSlots: { customRender: "action" },
        },
      ],
      skillPropertyKeys: {},
      // 技能分类数字字典
      skillTypeKeys: {},      
      url: {
        list: '/mes-manpower/mesHrSkillBank/list',
        delete: '/mes-manpower/mesHrSkillBank',
        editStatus: '/mes-manpower/mesHrSkillBank/updateStatus',
      },
    
      layout: {
        labelCol: { span: 4 },
        wrapperCol: { span: 14 },
      },         
    }
  },
  mounted() {
    this.getAjaxGetDictItems()
  },
  methods: {

    // 获取数字字典
    getAjaxGetDictItems() {
      const arr = [
        { code: "	mes_skill_property", key: "skillPropertyKeys" },
        { code: "mes_skill_type", key: "skillTypeKeys" },
      ];
      getDictItemsArr(this, arr);
    },

    handleEdit(record){
      this.$refs.skillBankListModal.showModal(record)
    },
    // 显示新增弹窗
    showAddModal(){
      this.$refs.skillBankListModal.showModal()
    },
    handleSuccess(){
      this.$refs.renderTable.loadData()
    }
  },
  components: {
    RenderTable,
    SkillBankListModal
  }
}
</script>

<style lang="less" scoped>
</style>

